﻿/*
 * Created by SharpDevelop.
 * User: Ja
 * Date: 9/14/2011
 * Time: 6:36 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Drawing;
using System.Windows.Forms;

namespace bminterface
{
	/// <summary>
	/// Description of GraphPanel.
	/// </summary>
	public partial class GraphPanel : Form
	{
		long previousTicks = 0; // Used to generate testing plot values
		Random rand;			//
		
		public GraphPanel()
		{
			previousTicks = DateTime.Now.Ticks;
			rand = new Random(5);
			
			this.Show();
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}

        protected override CreateParams CreateParams
        {
            get
            {
                const int NOCLOSE_BUTTON = 0x200;

                CreateParams myParams = base.CreateParams;
                myParams.ClassStyle = myParams.ClassStyle | NOCLOSE_BUTTON;
                return myParams;
            }
        }

        // Sets location of the window.
        public void SetPostion( int x, int y)
        {
            this.Location = new Point( x, y );
        }

        // Timer is used temporary to modify content of the graphs.
		void GraphPanelTimerTick(object sender, EventArgs e)
		{
			long currTicks = DateTime.Now.Ticks;
			
			float x = ( float )(currTicks - previousTicks)/10000;
			
			double y = (rand.NextDouble()*20.0 - 10.0f);
			graph1.testAddRandom(x, (float) y);
			//graph1.Refresh();
			graph1.draw();
			
			graph4.testAddRandom2(x, (float) y);
			
			y = (rand.NextDouble()*20.0 - 10.0f);
			graph2.testAddRandom(x, (float) y);
			graph2.draw();
			
			graph1.testAddRandom2(x, (float) y);
			
			y = (rand.NextDouble()*20.0 - 10.0f);
			graph3.testAddRandom(x, (float) y);
			graph3.draw();
			
			graph2.testAddRandom2(x, (float) y);
			
			
			y = (rand.NextDouble()*20.0 - 10.0f);
			graph4.testAddRandom(x, (float) y);
			graph4.draw();
			
			
			graph3.testAddRandom2(x, (float) y);
			
			
		}
	}
}
